package com.yhsimon.factory.simplefactory.pizzastore.order;

import com.yhsimon.factory.simplefactory.pizzastore.pizza.Pizza;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


//优化
public class OrderPizza2 {
    Pizza pizza;
    String orderType;

    public OrderPizza2() {
        do {
            orderType = getType();
            pizza = SimpleFactory.createPizza2(orderType);
            if (pizza != null) {
                pizza.process();
            } else {
                System.out.println("披萨订购失败");
                break;
            }
        } while (true);
    }

    //获取客户希望订购的披萨种类
    private String getType(){
        try{
            BufferedReader strIn = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("input pizza type：");
            return strIn.readLine();
        }catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
